<style>
    .nav-title{
        display: none;
    }
</style>
<div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">

    <form class="layui-form" action="" method="post" >

        <div class="layui-form-item">

            <div class="layui-input-inline mw400">
                <textarea name="code" id="code" placeholder="请输入禁用命令" class="layui-textarea">{{.ban.code}}</textarea>
            </div>

        </div>
        <input type="hidden" name="id" id="id" value="{{.ban.id}}">
        <div class="layui-form-item">
            <div class="layui-input-inline mw400">
                <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    var $;
    layui.use(['form','element','layer','jquery'],function(){
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var $ = layui.jquery;
        var error_info = "{{.flash.error}}";
        if(error_info){
            layer.msg(error_info,{icon: 2,shade:0.3},function () {
                window.history.go(-1)
            })
            return;
        }
        form.on('submit(sub)', function(data){
            var form_data = data.field;
            $.post('{{urlfor "BanController.AjaxSave"}}', form_data, function (out) {
                if (out.status == 0) {
                    layer.msg("操作成功",{icon: 1,shade:0.3,time:1000},function () {
                        window.parent.layer.closeAll();
                        window.parent.location.reload();
                    })
                } else {
                    layer.msg(out.message)
                }
            }, "json");
            return false;
        });

        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();
    });
</script>